﻿using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using SystemCenterSoa.ApiProject.Area.SystemManager;
using SystemCenterSoa.DtoModel.Common;
using SystemCenterSoa.PoModel.SystemSettings.QualificationAdministration;
using SystemCenterSoa.Service.SystemSettings.QualificationAdministration;

namespace SystemCenterSoa.ApiProject.Area.SystemSettings.QualificationAdministration
{
    [AllowAnonymous]
    public class DictionaryTypeTableController : SystemManagerBaseController
    {
        private DictionaryTypeTableService _dictionaryTypeTableService;
        public DictionaryTypeTableController(DictionaryTypeTableService dictionaryTypeTableService)
        {
            _dictionaryTypeTableService = dictionaryTypeTableService;
        }
        [HttpPost]
        public ResultModel<bool> DictionaryTypeTableAdd(DictionaryTypeTablePo info)
        {
            try
            {
                info.creator_date = DateTime.Now;
                info.creator_name = LoginUser.user_full_name;
                var data = _dictionaryTypeTableService.DictionaryTypeTableAdd(info);
                return MyOk(data);
            }
            catch (Exception ex)
            {
                return MyError<bool>(ex);
            }
        }
        [HttpPost]
        public ResultModel<bool> DictionaryTypeTableDelete(string dbtypeKey)
        {
            try
            {
                var data = _dictionaryTypeTableService.DictionaryTypeTableDelete(dbtypeKey);
                return MyOk(data);
            }
            catch (Exception ex)
            {
                return MyError<bool>(ex);
            }
        }
        [HttpGet]
        public ResultModel<DictionaryTypeTablePo> DictionaryTypeTableEdit(string dbtypeKey)
        {
            try
            {
                var data = _dictionaryTypeTableService.DictionaryTypeTableEdit(dbtypeKey);
                return MyOk(data);
            }
            catch (Exception ex)
            {
                return MyError<DictionaryTypeTablePo>(ex);
            }
        }
        [HttpPost]
        public ResultModel<bool> DictionaryTypeTableUpdate(DictionaryTypeTablePo info)
        {
            try
            {
                info.modifi_date = DateTime.Now;
                info.modifi_name = LoginUser.user_full_name;
                var data = _dictionaryTypeTableService.DictionaryTypeTableUpdate(info);
                return MyOk(data);
            }
            catch (Exception ex)
            {
                return MyError<bool>(ex);
            }
        }
        [HttpPost]
        public ResultModel<PagerResult<DictionaryTypeTablePo>> SearchPage(SearchModel sm)
        {
            try
            {
                var data = _dictionaryTypeTableService.SearchPage(sm);
                return MyOk(data);
            }
            catch (Exception ex)
            {
                return MyError<PagerResult<DictionaryTypeTablePo>>(ex);
            }


        }
    }
}
